home *** CD-ROM | disk | FTP | other *** search
/ funcom 2000 Presskit / 000721_1312 (fun.com).iso / funcom.dir / 00025_Script_Set Color behavior < prev    next >
Text File  |  2000-07-20  |  2KB  |  50 lines

  1.  
  2.  
  3. -- Set Color behavior
  4.  
  5. -----------------------------------------------------------
  6. -- This behavior sets the color of a shape sprite in
  7. -- response to a sliderMove message from the slider 
  8. -- behavior. The message also contains a value between 0  
  9. -- and 100 representing the slider's current position.
  10. --
  11. -- You attach this behavior to a shape sprite.
  12. --
  13. -- David Benman 11/97
  14. -----------------------------------------------------------
  15.  
  16. -- pControlButtonName - The name of the button that
  17. -- controls this behavior.
  18. property pControlButtonName
  19.  
  20. -- This handler determines which control messages the 
  21. -- behavior responds to.
  22. on beginSprite me
  23.   set pControlButtonName to "Vertical Slider"
  24. end
  25.  
  26.  
  27. -- This handler responds to a sliderMove message by
  28. -- changing the sprite's color. The color changes only 
  29. -- when the behavior sending the message is the controlling
  30. -- button for this behavior.
  31. on sliderMove me, messageSenderName, ratio
  32.   
  33.   -- Sets the color of the current sprite to a palette 
  34.   -- position between 36 and 179. These palette positions
  35.   -- contain identical colors in the Netscape, Macintosh, 
  36.   -- and Windows palettes.
  37.   if  messageSenderName = pControlButtonName then
  38.     set startColor to 36
  39.     set endColor to 179
  40.     set totalColors = endColor - startColor
  41.     set currentColor to totalColors * (ratio/100)
  42.     set colorPosition to currentColor + startColor
  43.     set newColor to integer(colorPosition)
  44.     set currentSprite to the spriteNum of me
  45.     set the forecolor of sprite currentSprite to newColor
  46.   end if
  47.   
  48. end
  49.  
  50.